package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.IdleAffiliateCpsIncomeDetail;
import com.ruoyi.system.service.IIdleAffiliateCpsIncomeDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 闲鱼联盟CPS佣金明细Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/income")
public class IdleAffiliateCpsIncomeDetailController extends BaseController
{
    @Autowired
    private IIdleAffiliateCpsIncomeDetailService idleAffiliateCpsIncomeDetailService;

    /**
     * 查询闲鱼联盟CPS佣金明细列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(IdleAffiliateCpsIncomeDetail idleAffiliateCpsIncomeDetail)
    {
        startPage();
        List<IdleAffiliateCpsIncomeDetail> list = idleAffiliateCpsIncomeDetailService.selectIdleAffiliateCpsIncomeDetailList(idleAffiliateCpsIncomeDetail);
        return getDataTable(list);
    }

    /**
     * 导出闲鱼联盟CPS佣金明细列表
     */
    @Anonymous
    @Log(title = "闲鱼联盟CPS佣金明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IdleAffiliateCpsIncomeDetail idleAffiliateCpsIncomeDetail)
    {
        List<IdleAffiliateCpsIncomeDetail> list = idleAffiliateCpsIncomeDetailService.selectIdleAffiliateCpsIncomeDetailList(idleAffiliateCpsIncomeDetail);
        ExcelUtil<IdleAffiliateCpsIncomeDetail> util = new ExcelUtil<IdleAffiliateCpsIncomeDetail>(IdleAffiliateCpsIncomeDetail.class);
        util.exportExcel(response, list, "闲鱼联盟CPS佣金明细数据");
    }

    /**
     * 获取闲鱼联盟CPS佣金明细详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(idleAffiliateCpsIncomeDetailService.selectIdleAffiliateCpsIncomeDetailById(id));
    }

    /**
     * 新增闲鱼联盟CPS佣金明细
     */
    @Anonymous
    @Log(title = "闲鱼联盟CPS佣金明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IdleAffiliateCpsIncomeDetail idleAffiliateCpsIncomeDetail)
    {
        return toAjax(idleAffiliateCpsIncomeDetailService.insertIdleAffiliateCpsIncomeDetail(idleAffiliateCpsIncomeDetail));
    }

    /**
     * 修改闲鱼联盟CPS佣金明细
     */
    @Anonymous
    @Log(title = "闲鱼联盟CPS佣金明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IdleAffiliateCpsIncomeDetail idleAffiliateCpsIncomeDetail)
    {
        return toAjax(idleAffiliateCpsIncomeDetailService.updateIdleAffiliateCpsIncomeDetail(idleAffiliateCpsIncomeDetail));
    }

    /**
     * 删除闲鱼联盟CPS佣金明细
     */
    @Anonymous
    @Log(title = "闲鱼联盟CPS佣金明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(idleAffiliateCpsIncomeDetailService.deleteIdleAffiliateCpsIncomeDetailByIds(ids));
    }

    /**
     * 根据账单ID查询闲鱼联盟CPS佣金明细
     */
    @Anonymous
    @GetMapping("/bill/{billId}")
    public AjaxResult getInfoByBillId(@PathVariable("billId") String billId)
    {
        return success(idleAffiliateCpsIncomeDetailService.selectIdleAffiliateCpsIncomeDetailByBillId(billId));
    }

    /**
     * 根据订单ID查询闲鱼联盟CPS佣金明细
     */
    @Anonymous
    @GetMapping("/order/{orderId}")
    public AjaxResult getInfoByOrderId(@PathVariable("orderId") String orderId)
    {
        return success(idleAffiliateCpsIncomeDetailService.selectIdleAffiliateCpsIncomeDetailByOrderId(orderId));
    }

    /**
     * 获取CPS收入明细统计信息
     */
    @Anonymous
    @GetMapping("/statistics")
    public AjaxResult getStatistics()
    {
        return success(idleAffiliateCpsIncomeDetailService.getCpsIncomeStatistics());
    }
} 